package com.fhz.kotlinmvvm.main

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.fhz.kotlinmvvm.entity.Banner
import com.fhz.kotlinmvvm.entity.Goods
import com.fhz.kotlinmvvm.entity.ResponseApi
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.launch
import javax.inject.Inject

/**
 * 时间:2023/9/12
 * @author Mr.Feng
 * 简述: TODO
 */
@HiltViewModel
class MainViewModel @Inject constructor (val mainRepository: MainRepository) : ViewModel() {

   suspend fun getBanners(type:Int,page:Int,pageSize:Int) : ResponseApi<Banner> {
        return mainRepository.getBanners(type, page, pageSize)
    }

    suspend fun getGoodsList(page:Int,pageSize:Int) : ResponseApi<Goods> {
        val goodsList = mainRepository.getGoodsList(page, pageSize)
        goodsList.data.list.asFlow().run {

        }
        return mainRepository.getGoodsList(page, pageSize)
    }

    suspend fun insertGoods(goods: Goods){
        mainRepository.insertGoods(goods)
    }

    fun test(){
        val s  = listOf<String>("1")

    }
}